import React, {Component} from 'react';

import './index.less';

import {
    base
} from 'nc-lightapp-front';

const {
    NCModal,
    NCButton,
    NCTable
} = base;

const {
    Header: ModalHeader,
    Body: ModalBody,
    Footer: ModalFooter
} = NCModal;


class SaveErrorMsgModal extends Component {
    constructor(props) {
        super(props);
        this.state = {};
    }

    onSure = () => {
        this.props.onSure()
    }

    onClose = () => {
        this.props.onClose()
    }

    render() {
        const {
            visible,
            errorMsgData,
            json = {}
        } = this.props;

        const {errorStaffList, errorStatus} = errorMsgData

        return (
            <NCModal
                className={'error-msg-modal flex-container'}
                show={visible}
                onCancel={this.onClose}
                height={522}
                size='lg'
            >
                <ModalHeader
                    closeButton={true}
                >
                    <div className={' base-modal-title wui-modal-title'}>
                        <span>{json['hrkq-0000102']}</span>
                    </div>
                </ModalHeader>
                <ModalBody>
                    <div className={'error-msg-title'}>
                        {errorStatus === '1' ? json['hrkq-0000146']
                            : json['hrkq-0000147']}
                    </div>
                    <div className={'error-msg-table flex-container'}>
                        <NCTable
                            columns={[
                                {
                                    key: 'staffCode', //列的键
                                    dataIndex: 'staffCode', //列的键
                                    title: json['hrkq-0000018'], //员工编码
                                    width: 150
                                },
                                {
                                    key: 'staffName',
                                    dataIndex: 'staffName',
                                    title: json['hrkq-0000014'],
                                    width: 150
                                },
                                {
                                    key: 'message',
                                    dataIndex: 'message',
                                    title: json['hrkq-0000142'],
                                    width: 450
                                }]}
                            data={errorStaffList}
                        />
                    </div>
                </ModalBody>
                <ModalFooter>
                    <div
                        style={{
                            textAlign: 'right'
                        }}
                    >
                        {errorStatus === '1' && <NCButton
                            colors="primary"
                            onClick={this.onSure}
                        >
                            {json['hrkq-0000143']}
                        </NCButton>}
                        {errorStatus === '1' && <NCButton
                            onClick={this.onClose}
                        >
                            {json['hrkq-0000144']}
                        </NCButton>}
                        {errorStatus === '2' && <NCButton
                            colors="primary"
                            onClick={this.onClose}
                        >
                            {json['hrkq-0000145']}
                        </NCButton>}
                    </div>
                </ModalFooter>
            </NCModal>
        );
    }
}

export default SaveErrorMsgModal;
